        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>Transform class / box2d Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d" data-type="Transform">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d.html">box2d</a> &rsaquo; <a href="../box2d/Transform.html">Transform</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>Transform</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<pre class="source">
class Transform {
 /** The translation caused by a transform. */
 final vec2 position;

 /** A matrix representing a rotation. */
 final mat2 rotation;

 /**
  * Constructs a new transform with a vector at the origin and no rotation.
  */
 Transform() : position = new vec2.zero(), rotation = new mat2.zero();

 /**
  * Constructs a new transform equal to the given transform.
  */
 Transform.copy(Transform other)
     : position = new vec2.copy(other.position),
       rotation = new mat2.copy(other.rotation);

 bool operator ==(other) {
   return position == other.position &amp;&amp; rotation == other.rotation;
 }

 /**
  * Sets this transform with the given position and rotation.
  */
 void setFromPositionAndRotation(vec2 argPosition, mat2 argRotation) {
   position.copyFrom(argPosition);
   rotation.copyFrom(argRotation);
 }

 /**
  * Sets this transform equal to the given transform.
  */
 void setFrom(Transform other) {
   position.copyFrom(other.position);
   rotation.copyFrom(other.rotation);
 }

 /**
  * Multiply the given transform and given vector and return a new vec2 with
  * the result.
  */
 static vec2 mul(Transform T, vec2 v) {
   return new vec2(T.position.x + T.rotation.col0.x * v.x +
       T.rotation.col1.x * v.y, T.position.y + T.rotation.col0.y * v.x +
       T.rotation.col1.y * v.y);
 }

 /**
  * Multiplies the given transform and the given vector and places the result
  * in the given out parameter.
  */
 static void mulToOut(Transform transform, vec2 vector, vec2 out) {
   assert(out != null);
   num tempY = transform.position.y + transform.rotation.col0.y *
       vector.x + transform.rotation.col1.y * vector.y;
   out.x = transform.position.x + transform.rotation.col0.x * vector.x +
       transform.rotation.col1.x * vector.y;
   out.y = tempY;
 }

 static void mulTransToOut(Transform T, vec2 v, vec2 out) {
   vec2 v1 = v - T.position;
   vec2 b = T.rotation.col0;
   vec2 b1 = T.rotation.col1;
   num tempy = v1.x * b1.x + v1.y * b1.y;
   out.x = v1.x * b.x + v1.y * b.y;
   out.y = tempy;
 }
}
</pre>
</div>
<div>
<h3>Static Methods</h3>
<div class="method"><h4 id="mul">
<button class="show-code">Code</button>
<a href="../vector_math/vec2.html">vec2</a> <strong>mul</strong>(<a href="../box2d/Transform.html">Transform</a> T, <a href="../vector_math/vec2.html">vec2</a> v) <a class="anchor-link" href="#mul"
              title="Permalink to Transform.mul">#</a></h4>
<div class="doc">
<p>Multiply the given transform and given vector and return a new vec2 with
the result.</p>
<pre class="source">
static vec2 mul(Transform T, vec2 v) {
 return new vec2(T.position.x + T.rotation.col0.x * v.x +
     T.rotation.col1.x * v.y, T.position.y + T.rotation.col0.y * v.x +
     T.rotation.col1.y * v.y);
}
</pre>
</div>
</div>
<div class="method"><h4 id="mulToOut">
<button class="show-code">Code</button>
void <strong>mulToOut</strong>(<a href="../box2d/Transform.html">Transform</a> transform, <a href="../vector_math/vec2.html">vec2</a> vector, <a href="../vector_math/vec2.html">vec2</a> out) <a class="anchor-link" href="#mulToOut"
              title="Permalink to Transform.mulToOut">#</a></h4>
<div class="doc">
<p>Multiplies the given transform and the given vector and places the result
in the given out parameter.</p>
<pre class="source">
static void mulToOut(Transform transform, vec2 vector, vec2 out) {
 assert(out != null);
 num tempY = transform.position.y + transform.rotation.col0.y *
     vector.x + transform.rotation.col1.y * vector.y;
 out.x = transform.position.x + transform.rotation.col0.x * vector.x +
     transform.rotation.col1.x * vector.y;
 out.y = tempY;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mulTransToOut">
<button class="show-code">Code</button>
void <strong>mulTransToOut</strong>(<a href="../box2d/Transform.html">Transform</a> T, <a href="../vector_math/vec2.html">vec2</a> v, <a href="../vector_math/vec2.html">vec2</a> out) <a class="anchor-link" href="#mulTransToOut"
              title="Permalink to Transform.mulTransToOut">#</a></h4>
<div class="doc">
<pre class="source">
static void mulTransToOut(Transform T, vec2 v, vec2 out) {
 vec2 v1 = v - T.position;
 vec2 b = T.rotation.col0;
 vec2 b1 = T.rotation.col1;
 num tempy = v1.x * b1.x + v1.y * b1.y;
 out.x = v1.x * b.x + v1.y * b.y;
 out.y = tempy;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="Transform">
<button class="show-code">Code</button>
new <strong>Transform</strong>() <a class="anchor-link" href="#Transform"
              title="Permalink to Transform.Transform">#</a></h4>
<div class="doc">
<p>Constructs a new transform with a vector at the origin and no rotation.</p>
<pre class="source">
Transform() : position = new vec2.zero(), rotation = new mat2.zero();
</pre>
</div>
</div>
<div class="method"><h4 id="Transform.copy">
<button class="show-code">Code</button>
new <strong>Transform.copy</strong>(<a href="../box2d/Transform.html">Transform</a> other) <a class="anchor-link" href="#Transform.copy"
              title="Permalink to Transform.Transform.copy">#</a></h4>
<div class="doc">
<p>Constructs a new transform equal to the given transform.</p>
<pre class="source">
Transform.copy(Transform other)
   : position = new vec2.copy(other.position),
     rotation = new mat2.copy(other.rotation);
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="position">
<button class="show-code">Code</button>
final <a href="../vector_math/vec2.html">vec2</a>         <strong>position</strong> <a class="anchor-link"
            href="#position"
            title="Permalink to Transform.position">#</a>
        </h4>
        <div class="doc">
<pre class="source">
position
</pre>
</div>
</div>
<div class="field"><h4 id="rotation">
<button class="show-code">Code</button>
final <a href="../vector_math/mat2.html">mat2</a>         <strong>rotation</strong> <a class="anchor-link"
            href="#rotation"
            title="Permalink to Transform.rotation">#</a>
        </h4>
        <div class="doc">
<pre class="source">
rotation
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method"><h4 id="==">
<button class="show-code">Code</button>
bool <strong>operator ==</strong>(other) <a class="anchor-link" href="#=="
              title="Permalink to Transform.operator ==">#</a></h4>
<div class="doc">
<div class="inherited">
<p>The equality operator.</p>
<p>The default behavior for all <code>Object</code>s is to return true if and
only if <code>this</code> and 
<span class="param">other</span> are the same object.</p>
<p>If a subclass overrides the equality operator it should override
the <code>hashCode</code> method as well to maintain consistency.</p>
<div class="docs-inherited-from">docs inherited from Object </div></div>
<pre class="source">
bool operator ==(other) {
 return position == other.position &amp;&amp; rotation == other.rotation;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="setFrom">
<button class="show-code">Code</button>
void <strong>setFrom</strong>(<a href="../box2d/Transform.html">Transform</a> other) <a class="anchor-link" href="#setFrom"
              title="Permalink to Transform.setFrom">#</a></h4>
<div class="doc">
<p>Sets this transform equal to the given transform.</p>
<pre class="source">
void setFrom(Transform other) {
 position.copyFrom(other.position);
 rotation.copyFrom(other.rotation);
}
</pre>
</div>
</div>
<div class="method"><h4 id="setFromPositionAndRotation">
<button class="show-code">Code</button>
void <strong>setFromPositionAndRotation</strong>(<a href="../vector_math/vec2.html">vec2</a> argPosition, <a href="../vector_math/mat2.html">mat2</a> argRotation) <a class="anchor-link" href="#setFromPositionAndRotation"
              title="Permalink to Transform.setFromPositionAndRotation">#</a></h4>
<div class="doc">
<p>Sets this transform with the given position and rotation.</p>
<pre class="source">
void setFromPositionAndRotation(vec2 argPosition, mat2 argRotation) {
 position.copyFrom(argPosition);
 rotation.copyFrom(argRotation);
}
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
